package cn.cubic.sys.modular.customerinfo.controller;

import cn.cubic.core.annotion.BusinessLog;
import cn.cubic.core.enums.LogAnnotionOpTypeEnum;
import cn.cubic.core.pojo.response.ResponseData;
import cn.cubic.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.cubic.sys.modular.customerinfo.service.CustomerInfoService;
import cn.cubic.sys.modular.customerinfo.model.param.CustomerInfoParam;

import javax.annotation.Resource;

/**
 * 客户信息表 控制器
 */
@RestController
public class CustomerInfoController {

    @Resource
    private CustomerInfoService customerInfoService;

    /**
     * 分页查询客户信息表
     */
    @GetMapping("/customerInfo/page")
    @BusinessLog(title = "客户信息表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CustomerInfoParam customerInfoParam) {
        return new SuccessResponseData(customerInfoService.page(customerInfoParam));
    }

    /**
     * 获取全部客户信息表
     */
    @GetMapping("/customerInfo/list")
    @BusinessLog(title = "客户信息表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CustomerInfoParam customerInfoParam) {
        return new SuccessResponseData(customerInfoService.list(customerInfoParam));
    }

    /**
     * 查看详情客户信息表
     */
    @GetMapping("/customerInfo/detail")
    @BusinessLog(title = "客户信息表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CustomerInfoParam.detail.class) CustomerInfoParam customerInfoParam) {
        return new SuccessResponseData(customerInfoService.detail(customerInfoParam));
    }

    /**
     * 添加客户信息表
     */
    @PostMapping("/customerInfo/add")
    @BusinessLog(title = "客户信息表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CustomerInfoParam.add.class) CustomerInfoParam customerInfoParam) {
        customerInfoService.add(customerInfoParam);
        return new SuccessResponseData();
    }

    /**
     * 删除客户信息表
     */
    @PostMapping("/customerInfo/delete")
    @BusinessLog(title = "客户信息表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CustomerInfoParam.delete.class) CustomerInfoParam customerInfoParam) {
        customerInfoService.delete(customerInfoParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑客户信息表
     */
    @PostMapping("/customerInfo/edit")
    @BusinessLog(title = "客户信息表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CustomerInfoParam.edit.class) CustomerInfoParam customerInfoParam) {
        customerInfoService.edit(customerInfoParam);
        return new SuccessResponseData();
    }


}
